<script setup lang="ts">
import SearchTop from "@/components/index/search/SearchTop.vue";
import SearchSection from "@/components/index/search/SearchSection.vue";
import {useRoute, useRouter} from "vue-router";
import {searchContent} from "@/http/home";
import {ref, watch} from "vue";

const router = useRouter()
const route = useRoute()
const keyword = ref(route.params.keyword)
const searchInfo = ref({
    psyTeacherVos:[],
    psyArticleVos:[]
})

function initData() {
    searchContent({name: route.params.keyword as string}).then(res => {
        if (res.code == 200) {
            searchInfo.value = res.data
        }
    })
}

initData()

const handleSearch = (keyword)=>{
    // 根据keywords进行界面跳转
    router.push({
        name: 'searchResult',
        params: {keyword}
    })
}

watch(route,()=>initData())

</script>


<template>
  <!--    {{searchInfo.psyTeacherVos}}-->
    <div>
        <search-top v-model="keyword" @search="handleSearch"></search-top>
        <search-section :searchInfo="searchInfo"></search-section>
    </div>
</template>

<style scoped>

</style>



